class Solution {
public:
    vector<string> summaryRanges(vector<int>& nums) {
        vector<string>ans;
        if (nums.size() == 0)return ans;
        int n = nums.size();
        for (int i = 0; i < n;) {
            int l = i;
            int r = i;
            while (r + 1 < n && nums[r] + 1 == nums[r + 1]) {
                r++;
            }
            cout << "l===" << l << endl;
            cout << "r===" << r << endl;
            string s;
            if (l == r) {
                i++;
                s = to_string(nums[l]);
                ans.push_back(s);
            }
            else {
                i = r + 1;
                s += to_string(nums[l]);
                s += "->";
                s += to_string(nums[r]);
                ans.push_back(s);
            }
        }
        return ans;
    }
};